function [F,DOF,P]=FTest(b,R,varb,TT,r)

size(varb);

n=length(b);
DOF=rank(R);%rank=n-rank(null(H0));....

if nargin<4;
 global TT
 disp('is T global? Check results');
end;

if nargin<5;
r=zeros(size(R));
r=r(:,1);
end;


F=(R*b-r)'*inv(R*varb*R')*(R*b-r)/DOF;
P=1-fcdf(F,DOF,TT-n);







